Return to start page

Core/Environment/Library Terrain.j

Code

		
1			library ALibraryCoreEnvironmentTerrain
2
3 /**
4 * Original description:
5 * The function SetTerrainPathable sets a single 32x32 space on the pathing grid. However, SetTerrainType sets a
6 * 128x128 space on the terrain grid, and does not change the pathing for that space. If you want to change the
7 * pathing, you'd have to change the pathing for 16 individual points per terrain space. This function rectifies
8 * the situation by allowing you to change the pathing for a single space on the terrain grid, instead of a single
9 * space on the pathing grid.
10 * Note: In my tests, the alignment was correct. However, there might be cases where this isn't true, so if there
11 * is a problem I will change the numbers as needed.
12 * @author Shvegait
13 * @source http://www.wc3jass.com/
14 */
15 function SetTerrainSpacePathable takes real x, real y, pathingtype pathingType, boolean flag returns nothing
16 local real newX = x + 64.0
17 local real newY = y + 64.0
18 local integer i
19 local integer j
20 set newX = (newX - ModuloReal(newX, 128.0) - 64.0)
21 set newY = (newY - ModuloReal(newY, 128.0) + 32.0)
22 set i = 0
23 loop
24 exitwhen (i > 3)
25 set j = 0
26 loop
27 exitwhen (j > 3)
28 call SetTerrainPathable((newX + i * 32.0) , (newY - j * 32.0), pathingType, flag)
29 set j = j + 1
30 endloop
31 set i = i + 1
32 endloop
33 endfunction
34
35 endlibrary